from django import forms
class Syaml(forms.Form):
    #error_messages= {'required': '不能为空', 'invalid': '格式错误'},widget=forms.TextInput(attrs={})
    author_s=forms.CharField(label='作者',max_length=100,strip=False,widget=forms.TextInput(attrs={'placeholder':"作者" }))
    # date_s=forms.DateTimeField()
    name_s=forms.CharField(label='用例名',max_length=100,strip=False,widget=forms.TextInput(attrs={'placeholder':"用例名",

                                                                                                }))
    # match_s=forms.CharField(label='匹配方式')
    # search_s=forms.CharField(label='搜索方式')
    # search_s = forms.MultipleChoiceField(label="搜索方法",TypedChoiceField=)
    search_choice=[('never',"搜索方式"),(0,'搜索方式：文件夹匹配'),(1,'搜索方式：文件名匹配')]
    match_choice=[('0','正样本匹配'),('1','负样本匹配'),('2','假币匹配'),('3','冠字号匹配')]  #0为正样本匹配模式  1为负样本匹配模式（目前和正样本一样） 2为假币的匹配模式  3为冠字号匹配模式
    start_command=[('0','开始命令'),('set --value_mode single/','set --value_mode single'),('set --value_mode mix/','set --value_mode mix'),('set --value_mode count/','set --value_mode count')]
    end_command=[('0','结束命令'),('set --value_mode single/','set --value_mode single'),('set --value_mode mix/','set --value_mode mix'),('set --value_mode count/','set --value_mode count')]
    #注意id必须为country css才能用
    search_s = forms.ChoiceField(choices=search_choice,widget=forms.Select(attrs={'onchange':"change_country(this.value)",
                                                                                                   'class':"frm-field required",
                                                                                                        'id':'country'
                                                                                          }))
    match_s = forms.ChoiceField(choices=match_choice,
                                         widget=forms.Select(attrs={'onchange': "change_country(this.value)",
                                                                    'class': "frm-field required",
                                                                    'id': 'country'
                                                                    }))
    # file_path=forms.FileField(widget=forms.ClearableFileInput(attrs={'webkitdirectory directory multiple':""}))
    file_path=forms.CharField(label='样本位置',max_length=500,strip=False,widget=forms.TextInput(attrs={'placeholder':"样本位置" ,
                                                                                                  'style':"width:900",}))
    # xml_path=forms.CharField(label='绑定的xml路径',max_length=500,strip=False,widget=forms.TextInput(attrs={'placeholder':"绑定的xml路径" ,
    #                                                                                               'style':"width:900",}))
    # start_s=forms.CharField(label='开始命令',max_length=500,strip=False,widget=forms.TextInput(attrs={'placeholder':"开始命令" ,
    #                                                                                               'style':"width:600",}))
    # end_s=forms.CharField(label='结束命令',max_length=500,strip=False,widget=forms.TextInput(attrs={'placeholder':"结束命令" ,
    #                                                                                               'style':"width:900",}))
    start_s = forms.ChoiceField(choices=start_command,widget=forms.Select(attrs={'onchange':"change_country(this.value)",
                                                                                                   'class':"frm-field required",
                                                                                                        'id':'country'
                                                                                          }))
    end_s = forms.ChoiceField(choices=end_command,widget=forms.Select(attrs={'onchange':"change_country(this.value)",
                                                                                                   'class':"frm-field required",
                                                                                                        'id':'country'
                                                                                          }))
    purpos_s=forms.CharField(label='备注',max_length=800,strip=False,widget=forms.Textarea(attrs={'placeholder':"填写备注" ,
                                                                                                  }))


from file_manage import models
class Tyaml(forms.Form):
    #上传多个文件
    # file_s_yaml = forms.FileField(widget=forms.ClearableFileInput(attrs={'multiple': True}))
    #将总用例需要跑的app位置
    # app_choice=[("0","APP选择"),("JULONG","聚龙")]
    app_choice=[]
    for tmp in models.App.objects.all():
        app_choice.append((tmp.app_path,tmp.name))
    search_T = forms.ChoiceField(choices=app_choice,
                                 widget=forms.Select(attrs={'onchange': "change_country(this.value)",
                                                            'class': "frm-field required",
                                                            'id': 'country'
                                                            }))
